package com.testing.vip12splogin.controller;

import com.testing.vip12splogin.mapper.UserMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Classname HelloSpring
 * @Description 类型说明
 * @Date 2022/5/19 20:33
 * @Created by 特斯汀Roy
 */
//基于restful风格创建的接口类。
@RestController
//指定url路径,produces参数表示返回的类型
@RequestMapping(value = "/hello",produces = "application/json")
@Api(tags="欢迎类control",description = "第一个接口类")
public class HelloSpring {

    @Autowired
    UserMapper userMapper;

    @ApiOperation(value="get请求hello",notes="请求可以通过输入url参数和?参数来进行输出")
    @GetMapping("/{teacher}")
    public String hello(@ApiParam(name="名字",value="初步调试") @PathVariable String teacher, @RequestParam String age){
        System.out.println("".equals(age));
        return "hello Spring "+teacher +"我猜你今年"+age;
    }

    @ApiOperation("post请求hello")
    @PostMapping
    public String helloPost(@ApiParam(name="用户名",value="用户名") @RequestParam String username,String password){
        userMapper.insertUser(username,password,"昵称","描述");
        return "用户民是"+username+"密码是"+password;
    }


}
